<?php
namespace App\Http\Controllers\Admin;
use App\DTOS\Admin\ActiveRuleSearchDTO;
use App\Models\ActiveRule;
use App\Models\ActiveRuleOline;
use App\Models\ActiveRuleOlineqd;
use App\Models\ActiveRuleOlineqdTc;
use App\Models\ActiveRuleOlineTc;
use App\Models\ActiveRuleQd;
use App\Models\ActiveRuleQdTc;
use App\Models\ActiveRuleTc;
use App\Services\Game\ActiveRuleService;
use App\Utils\MyLog;
use Maatwebsite\Excel\Facades\Excel;
use App\Exports\ExcelExport;
use App\Http\Controllers\Controller;
use App\Utils\ResponseUtil;
use App\DTOS\Admin\FeedBackSearchDTO;
use App\Services\FeedBackService;
use App\DTOS\Admin\FeedBackInsertDTO;
use App\DTOS\Admin\FeedBackUpdateDTO;
// 活动排期表
class ActiveRuleController extends Controller
{
    private ActiveRuleService $service;

    /**
     * FeedBackService constructor.
     * @param ActiveRuleService $service
     */
    public function __construct(ActiveRuleService $service)
    {
        $this->service = $service;
    }

    public function paginate()
    {
        $DTO = new ActiveRuleSearchDTO(request()->all());
        $paginate = $this->service->paginate($DTO);
        $data = $paginate->items();

        $res = [];
        $res['code'] = 0;
        $res['data'] = $data;
        $res['count'] = $paginate->total();
        return ResponseUtil::json($res);
    }


    public function push()
    {
        $activeRule = ActiveRule::query()->get();
        if (!$activeRule->isEmpty()) {
            try {


                $excelRows = [
                    ['编号', '活动名称', '规则表id', '后台备注', '后台服分组', '服务器类型', '服务器', '时间类型', '开启时间', '结束时间', "活动控制类型", "活动控制值", "每日限时时间段开始", "每日限时时间段结束",
                        "活动每日刷新时间", "显示在哪个功能UI中"
                        , "功能按钮时间", "是否播报", "转生后显示", "互斥活动","提前显示时间","持续显示时间"]
                ];
                foreach ($activeRule as $datum) {
                    $serverListArray = explode(',', $datum['ServerList']); // 以逗号分隔转换为数组

                    $servelist = implode('*', $serverListArray); // 用 * 拼接数组元素
                    $excelRows[] = [
                        $datum['num'], $datum['name'], $datum['TypeId'], $datum['rmark'], $datum['serverGroup'], $datum['ServerType'], $servelist, $datum['TimeType'],
                        $datum['TimeOpen'], $datum['TimeEnd'], $datum['LoopType'], $datum['LoopVal'], $datum['LoopDayTimeLimitStart'], $datum['LoopDayTimeLimitEnd']
                        , $datum['DayRefreshTime'], $datum['UIInFuncId']
                        , $datum['UIInFuncIdParam'], $datum['IsSysMsg'], $datum['Rebirth'], $datum['ExclusionAction'],$datum['AdvanceDisplay'],$datum['ContinuousDisplay']
                    ];
                }
                //将数据按照CSV格式导入本地
                $content = arrayToScvContent($excelRows);
                //$content =$excelRows;
                $filePath = 'ActiveRule/' . "ActivityCfg.csv";
                $dirname = dirname($filePath);


                if (!is_dir($dirname)) {
                    if (!mkdir($dirname, 0777, true)) {
                        throw new \Exception('Failed to create directory: ' . $dirname);
                    }
                }
                // 如果文件已存在，先删除它
                if (file_exists($filePath)) {
                    unlink($filePath); // 删除已有的文件
                }

                file_put_contents($filePath, $content);
                MyLog::info('当前目录' . json_encode($filePath));
                //上传远端服务器
                $uploadResponse = uploadFile($filePath, 'Config/CSV/Activity/');
                $responseData = json_decode($uploadResponse, true); // 将 JSON 字符串解析为数组

                if (isset($responseData['success']) && $responseData['success'] === true) {
                    ActiveRuleOline::query()->truncate();

                    // 同步到 ActiveRuleOnline 表
                    foreach ($activeRule as $datum) {
                        ActiveRuleOline::query()->updateOrInsert(
                            ['num' => $datum['num']], //
                            [
                                'name' => $datum['name'],
                                'TypeId' => $datum['TypeId'],
                                'rmark' => $datum['rmark'],
                                'serverGroup' => $datum['serverGroup'],
                                'ServerType' => $datum['ServerType'],
                                'ServerList' => $datum['ServerList'],
                                'TimeType' => $datum['TimeType'],
                                'TimeOpen' => $datum['TimeOpen'],
                                'TimeEnd' => $datum['TimeEnd'],
                                'LoopType' => $datum['LoopType'],
                                'LoopVal' => $datum['LoopVal'],
                                'DayRefreshTime' => $datum['DayRefreshTime'],
                                'LoopDayTimeLimitStart'=>$datum['LoopDayTimeLimitStart'],
                                'LoopDayTimeLimitEnd'=>$datum['LoopDayTimeLimitEnd'],
                                'UIInFuncId' => $datum['UIInFuncId'],
                                'UIInFuncIdParam' => $datum['UIInFuncIdParam'],
                                'IsSysMsg' => $datum['IsSysMsg'],
                                'Rebirth' => $datum['Rebirth'],
                                'ExclusionAction' => $datum['ExclusionAction'],
                                'AdvanceDisplay' => $datum['AdvanceDisplay'],
                                'ContinuousDisplay' => $datum['ContinuousDisplay'],
                                'updated_at' => time()

                            ]
                        );
                    }
                    return ResponseUtil::success();
                } else {
                    throw new \Exception('File upload failed');
                }

                return ResponseUtil::success();

            } catch
            (\Exception $e) {
                return ResponseUtil::error($e->getMessage());
            }

        }
        return ResponseUtil::error();


    }




    public function edit($id)
    {
        try{

            $DTO = new ActiveRuleSearchDTO(request()->post());
            $this->service->updateById($id,$DTO);
            return ResponseUtil::success();
        } catch (\Exception $e){
            return ResponseUtil::error($e->getMessage());
        }
    }

    public function delete($id){
        try{
            $this->service->deleteById($id);
            return ResponseUtil::success();
        } catch (\Exception $e){
            return ResponseUtil::error($e->getMessage());
        }
    }
    public function detail($id)
    {
        $data = $this->service->getById($id);
        return ResponseUtil::success($data);
    }

    public function add() {
        // 获取请求的数据
        $data = request()->only([
            'num',
            'name',
            'TypeId',
            'ServerType',
            'ServerList',
            'TimeType',
            'TimeOpen',
            'TimeEnd',
            'LoopType',
            'LoopVal',
            'LoopDayTimeLimitStart',
            'LoopDayTimeLimitEnd',
            'DayRefreshTime',
            'UIInFuncId',
            'UIInFuncIdParam',
            'IsSysMsg',
            'Rebirth',
            'ExclusionAction',
            'serverGroup',
             'rmark'
        ]);

        // 添加创建时间
        $data['created_at'] = date("Y-m-d H:i:s");

        // 插入数据
        ActiveRule::query()->insert($data);

        // 返回成功响应
        return ResponseUtil::success();
    }


    //渠道1

    public function paginateqd()
    {
        $DTO = new ActiveRuleSearchDTO(request()->all());
        $paginate = $this->service->paginateqd($DTO);
        $data = $paginate->items();

        $res = [];
        $res['code'] = 0;
        $res['data'] = $data;
        $res['count'] = $paginate->total();
        return ResponseUtil::json($res);
    }


    public function pushqd()
    {
        $activeRuleqd = ActiveRuleQd::query()->get();
        if (!$activeRuleqd->isEmpty()) {
            try {


                $excelRows = [
                    ['编号', '活动名称', '规则表id', '后台备注', '后台服分组', '服务器类型', '服务器', '时间类型', '开启时间', '结束时间', "活动控制类型", "活动控制值", "每日限时时间段开始", "每日限时时间段结束",
                        "活动每日刷新时间", "显示在哪个功能UI中"
                        , "功能按钮时间", "是否播报", "转生后显示", "互斥活动","提前显示时间","持续显示时间"]
                ];
                foreach ($activeRuleqd as $datum) {
                    $serverListArray = explode(',', $datum['ServerList']); // 以逗号分隔转换为数组

                    $servelist = implode('*', $serverListArray); // 用 * 拼接数组元素
                    $excelRows[] = [
                        $datum['num'], $datum['name'], $datum['TypeId'], $datum['rmark'], $datum['serverGroup'], $datum['ServerType'], $servelist, $datum['TimeType'],
                        $datum['TimeOpen'], $datum['TimeEnd'], $datum['LoopType'], $datum['LoopVal'], $datum['LoopDayTimeLimitStart'], $datum['LoopDayTimeLimitEnd']
                        , $datum['DayRefreshTime'], $datum['UIInFuncId']
                        , $datum['UIInFuncIdParam'], $datum['IsSysMsg'], $datum['Rebirth'], $datum['ExclusionAction'],$datum['AdvanceDisplay'],$datum['ContinuousDisplay']
                    ];
                }
                //将数据按照CSV格式导入本地
                $content = arrayToScvContent($excelRows);
                //$content =$excelRows;
                $filePath = 'ActiveRule/' . "ActivityCfg.csv";
                $dirname = dirname($filePath);


                if (!is_dir($dirname)) {
                    if (!mkdir($dirname, 0777, true)) {
                        throw new \Exception('Failed to create directory: ' . $dirname);
                    }
                }
                // 如果文件已存在，先删除它
                if (file_exists($filePath)) {
                    unlink($filePath); // 删除已有的文件
                }

                file_put_contents($filePath, $content);
                MyLog::info('当前目录' . json_encode($filePath));
                //上传远端服务器
                $uploadResponse = uploadFileqd($filePath, 'Config/CSV/Activity/');
                $responseData = json_decode($uploadResponse, true); // 将 JSON 字符串解析为数组

                if (isset($responseData['success']) && $responseData['success'] === true) {
                    ActiveRuleOlineqd::query()->truncate();

                    // 同步到 ActiveRuleOnline 表
                    foreach ($activeRuleqd as $datum) {
                        ActiveRuleOlineqd::query()->updateOrInsert(
                            ['num' => $datum['num']], //
                            [
                                'name' => $datum['name'],
                                'TypeId' => $datum['TypeId'],
                                'rmark' => $datum['rmark'],
                                'serverGroup' => $datum['serverGroup'],
                                'ServerType' => $datum['ServerType'],
                                'ServerList' => $datum['ServerList'],
                                'TimeType' => $datum['TimeType'],
                                'TimeOpen' => $datum['TimeOpen'],
                                'TimeEnd' => $datum['TimeEnd'],
                                'LoopType' => $datum['LoopType'],
                                'LoopVal' => $datum['LoopVal'],
                                'DayRefreshTime' => $datum['DayRefreshTime'],
                                'LoopDayTimeLimitStart'=>$datum['LoopDayTimeLimitStart'],
                                'LoopDayTimeLimitEnd'=>$datum['LoopDayTimeLimitEnd'],
                                'UIInFuncId' => $datum['UIInFuncId'],
                                'UIInFuncIdParam' => $datum['UIInFuncIdParam'],
                                'IsSysMsg' => $datum['IsSysMsg'],
                                'Rebirth' => $datum['Rebirth'],
                                'ExclusionAction' => $datum['ExclusionAction'],
                                'AdvanceDisplay' => $datum['AdvanceDisplay'],
                                'ContinuousDisplay' => $datum['ContinuousDisplay'],
                                'updated_at' => time()

                            ]
                        );
                    }
                    return ResponseUtil::success();
                } else {
                    throw new \Exception('File upload failed');
                }

                return ResponseUtil::success();

            } catch
            (\Exception $e) {
                return ResponseUtil::error($e->getMessage());
            }

        }
        return ResponseUtil::error();


    }




    public function editqd($id)
    {
        try{

            $DTO = new ActiveRuleSearchDTO(request()->post());
            $this->service->updateByIdqd($id,$DTO);
            return ResponseUtil::success();
        } catch (\Exception $e){
            return ResponseUtil::error($e->getMessage());
        }
    }

    public function deleteqd($id){
        try{
            $this->service->deleteByIdqd($id);
            return ResponseUtil::success();
        } catch (\Exception $e){
            return ResponseUtil::error($e->getMessage());
        }
    }
    public function detailqd($id)
    {
        $data = $this->service->getByIdqd($id);
        return ResponseUtil::success($data);
    }

    public function addqd() {
        // 获取请求的数据
        $data = request()->only([
            'num',
            'name',
            'TypeId',
            'ServerType',
            'ServerList',
            'TimeType',
            'TimeOpen',
            'TimeEnd',
            'LoopType',
            'LoopVal',
            'LoopDayTimeLimitStart',
            'LoopDayTimeLimitEnd',
            'DayRefreshTime',
            'UIInFuncId',
            'UIInFuncIdParam',
            'IsSysMsg',
            'Rebirth',
            'ExclusionAction',
            'serverGroup',
            'rmark'
        ]);

        // 添加创建时间
        $data['created_at'] = date("Y-m-d H:i:s");

        // 插入数据
        ActiveRuleQd::query()->insert($data);

        // 返回成功响应
        return ResponseUtil::success();
    }


    //官方提测
    public function paginatetc()
    {
        $DTO = new ActiveRuleSearchDTO(request()->all());
        $paginate = $this->service->paginatetc($DTO);
        $data = $paginate->items();

        $res = [];
        $res['code'] = 0;
        $res['data'] = $data;
        $res['count'] = $paginate->total();
        return ResponseUtil::json($res);
    }


    public function pushtc()
    {
        $activeRule = ActiveRuleTc::query()->get();
        if (!$activeRule->isEmpty()) {
            try {


                $excelRows = [
                    ['编号', '活动名称', '规则表id', '后台备注', '后台服分组', '服务器类型', '服务器', '时间类型', '开启时间', '结束时间', "活动控制类型", "活动控制值", "每日限时时间段开始", "每日限时时间段结束",
                        "活动每日刷新时间", "显示在哪个功能UI中"
                        , "功能按钮时间", "是否播报", "转生后显示", "互斥活动","提前显示时间","持续显示时间"]
                ];
                foreach ($activeRule as $datum) {
                    $serverListArray = explode(',', $datum['ServerList']); // 以逗号分隔转换为数组

                    $servelist = implode('*', $serverListArray); // 用 * 拼接数组元素
                    $excelRows[] = [
                        $datum['num'], $datum['name'], $datum['TypeId'], $datum['rmark'], $datum['serverGroup'], $datum['ServerType'], $servelist, $datum['TimeType'],
                        $datum['TimeOpen'], $datum['TimeEnd'], $datum['LoopType'], $datum['LoopVal'], $datum['LoopDayTimeLimitStart'], $datum['LoopDayTimeLimitEnd']
                        , $datum['DayRefreshTime'], $datum['UIInFuncId']
                        , $datum['UIInFuncIdParam'], $datum['IsSysMsg'], $datum['Rebirth'], $datum['ExclusionAction'],$datum['AdvanceDisplay'],$datum['ContinuousDisplay']
                    ];
                }
                //将数据按照CSV格式导入本地
                $content = arrayToScvContent($excelRows);
                //$content =$excelRows;
                $filePath = 'ActiveRule/' . "ActivityCfg.csv";
                $dirname = dirname($filePath);


                if (!is_dir($dirname)) {
                    if (!mkdir($dirname, 0777, true)) {
                        throw new \Exception('Failed to create directory: ' . $dirname);
                    }
                }
                // 如果文件已存在，先删除它
                if (file_exists($filePath)) {
                    unlink($filePath); // 删除已有的文件
                }

                file_put_contents($filePath, $content);
                MyLog::info('当前目录' . json_encode($filePath));
                //上传远端服务器
                $uploadResponse = uploadFiletc($filePath, 'Config/CSV/Activity/');
                $responseData = json_decode($uploadResponse, true); // 将 JSON 字符串解析为数组

                if (isset($responseData['success']) && $responseData['success'] === true) {
                    ActiveRuleOlineTc::query()->truncate();

                    // 同步到 ActiveRuleOnline 表
                    foreach ($activeRule as $datum) {
                        ActiveRuleOlineTc::query()->updateOrInsert(
                            ['num' => $datum['num']], //
                            [
                                'name' => $datum['name'],
                                'TypeId' => $datum['TypeId'],
                                'rmark' => $datum['rmark'],
                                'serverGroup' => $datum['serverGroup'],
                                'ServerType' => $datum['ServerType'],
                                'ServerList' => $datum['ServerList'],
                                'TimeType' => $datum['TimeType'],
                                'TimeOpen' => $datum['TimeOpen'],
                                'TimeEnd' => $datum['TimeEnd'],
                                'LoopType' => $datum['LoopType'],
                                'LoopVal' => $datum['LoopVal'],
                                'DayRefreshTime' => $datum['DayRefreshTime'],
                                'LoopDayTimeLimitStart'=>$datum['LoopDayTimeLimitStart'],
                                'LoopDayTimeLimitEnd'=>$datum['LoopDayTimeLimitEnd'],
                                'UIInFuncId' => $datum['UIInFuncId'],
                                'UIInFuncIdParam' => $datum['UIInFuncIdParam'],
                                'IsSysMsg' => $datum['IsSysMsg'],
                                'Rebirth' => $datum['Rebirth'],
                                'ExclusionAction' => $datum['ExclusionAction'],
                                'AdvanceDisplay' => $datum['AdvanceDisplay'],
                                'ContinuousDisplay' => $datum['ContinuousDisplay'],
                                'updated_at' => time()

                            ]
                        );
                    }
                    return ResponseUtil::success();
                } else {
                    throw new \Exception('File upload failed');
                }

                return ResponseUtil::success();

            } catch
            (\Exception $e) {
                return ResponseUtil::error($e->getMessage());
            }

        }
        return ResponseUtil::error();


    }




    public function edittc($id)
    {
        try{

            $DTO = new ActiveRuleSearchDTO(request()->post());
            $this->service->updateById($id,$DTO);
            return ResponseUtil::success();
        } catch (\Exception $e){
            return ResponseUtil::error($e->getMessage());
        }
    }

    public function deletetc($id){
        try{
            $this->service->deleteById($id);
            return ResponseUtil::success();
        } catch (\Exception $e){
            return ResponseUtil::error($e->getMessage());
        }
    }
    public function detailtc($id)
    {
        $data = $this->service->getById($id);
        return ResponseUtil::success($data);
    }

    public function addtc() {
        // 获取请求的数据
        $data = request()->only([
            'num',
            'name',
            'TypeId',
            'ServerType',
            'ServerList',
            'TimeType',
            'TimeOpen',
            'TimeEnd',
            'LoopType',
            'LoopVal',
            'LoopDayTimeLimitStart',
            'LoopDayTimeLimitEnd',
            'DayRefreshTime',
            'UIInFuncId',
            'UIInFuncIdParam',
            'IsSysMsg',
            'Rebirth',
            'ExclusionAction',
            'serverGroup',
            'rmark'
        ]);

        // 添加创建时间
        $data['created_at'] = date("Y-m-d H:i:s");

        // 插入数据
        ActiveRuleTc::query()->insert($data);

        // 返回成功响应
        return ResponseUtil::success();
    }

    //渠道提测

    public function paginateqdtc()
    {
        $DTO = new ActiveRuleSearchDTO(request()->all());
        $paginate = $this->service->paginateqdtc($DTO);
        $data = $paginate->items();

        $res = [];
        $res['code'] = 0;
        $res['data'] = $data;
        $res['count'] = $paginate->total();
        return ResponseUtil::json($res);
    }


    public function pushqdtc()
    {
        $activeRuleqd = ActiveRuleQdTc::query()->get();
        if (!$activeRuleqd->isEmpty()) {
            try {


                $excelRows = [
                    ['编号', '活动名称', '规则表id', '后台备注', '后台服分组', '服务器类型', '服务器', '时间类型', '开启时间', '结束时间', "活动控制类型", "活动控制值", "每日限时时间段开始", "每日限时时间段结束",
                        "活动每日刷新时间", "显示在哪个功能UI中"
                        , "功能按钮时间", "是否播报", "转生后显示", "互斥活动","提前显示时间","持续显示时间"]
                ];
                foreach ($activeRuleqd as $datum) {
                    $serverListArray = explode(',', $datum['ServerList']); // 以逗号分隔转换为数组

                    $servelist = implode('*', $serverListArray); // 用 * 拼接数组元素
                    $excelRows[] = [
                        $datum['num'], $datum['name'], $datum['TypeId'], $datum['rmark'], $datum['serverGroup'], $datum['ServerType'], $servelist, $datum['TimeType'],
                        $datum['TimeOpen'], $datum['TimeEnd'], $datum['LoopType'], $datum['LoopVal'], $datum['LoopDayTimeLimitStart'], $datum['LoopDayTimeLimitEnd']
                        , $datum['DayRefreshTime'], $datum['UIInFuncId']
                        , $datum['UIInFuncIdParam'], $datum['IsSysMsg'], $datum['Rebirth'], $datum['ExclusionAction'],$datum['AdvanceDisplay'],$datum['ContinuousDisplay']
                    ];
                }
                //将数据按照CSV格式导入本地
                $content = arrayToScvContent($excelRows);
                //$content =$excelRows;
                $filePath = 'ActiveRule/' . "ActivityCfg.csv";
                $dirname = dirname($filePath);


                if (!is_dir($dirname)) {
                    if (!mkdir($dirname, 0777, true)) {
                        throw new \Exception('Failed to create directory: ' . $dirname);
                    }
                }
                // 如果文件已存在，先删除它
                if (file_exists($filePath)) {
                    unlink($filePath); // 删除已有的文件
                }

                file_put_contents($filePath, $content);
                MyLog::info('当前目录' . json_encode($filePath));
                //上传远端服务器
                $uploadResponse = uploadFileqd($filePath, 'Config/CSV/Activity/');
                $responseData = json_decode($uploadResponse, true); // 将 JSON 字符串解析为数组

                if (isset($responseData['success']) && $responseData['success'] === true) {
                    ActiveRuleOlineqdTc::query()->truncate();

                    // 同步到 ActiveRuleOnline 表
                    foreach ($activeRuleqd as $datum) {
                        ActiveRuleOlineqdTc::query()->updateOrInsert(
                            ['num' => $datum['num']], //
                            [
                                'name' => $datum['name'],
                                'TypeId' => $datum['TypeId'],
                                'rmark' => $datum['rmark'],
                                'serverGroup' => $datum['serverGroup'],
                                'ServerType' => $datum['ServerType'],
                                'ServerList' => $datum['ServerList'],
                                'TimeType' => $datum['TimeType'],
                                'TimeOpen' => $datum['TimeOpen'],
                                'TimeEnd' => $datum['TimeEnd'],
                                'LoopType' => $datum['LoopType'],
                                'LoopVal' => $datum['LoopVal'],
                                'DayRefreshTime' => $datum['DayRefreshTime'],
                                'LoopDayTimeLimitStart'=>$datum['LoopDayTimeLimitStart'],
                                'LoopDayTimeLimitEnd'=>$datum['LoopDayTimeLimitEnd'],
                                'UIInFuncId' => $datum['UIInFuncId'],
                                'UIInFuncIdParam' => $datum['UIInFuncIdParam'],
                                'IsSysMsg' => $datum['IsSysMsg'],
                                'Rebirth' => $datum['Rebirth'],
                                'ExclusionAction' => $datum['ExclusionAction'],
                                'AdvanceDisplay' => $datum['AdvanceDisplay'],
                                'ContinuousDisplay' => $datum['ContinuousDisplay'],
                                'updated_at' => time()

                            ]
                        );
                    }
                    return ResponseUtil::success();
                } else {
                    throw new \Exception('File upload failed');
                }

                return ResponseUtil::success();

            } catch
            (\Exception $e) {
                return ResponseUtil::error($e->getMessage());
            }

        }
        return ResponseUtil::error();


    }




    public function editqdtc($id)
    {
        try{

            $DTO = new ActiveRuleSearchDTO(request()->post());
            $this->service->updateByIdqd($id,$DTO);
            return ResponseUtil::success();
        } catch (\Exception $e){
            return ResponseUtil::error($e->getMessage());
        }
    }

    public function deleteqdtc($id){
        try{
            $this->service->deleteByIdqd($id);
            return ResponseUtil::success();
        } catch (\Exception $e){
            return ResponseUtil::error($e->getMessage());
        }
    }
    public function detailqdtc($id)
    {
        $data = $this->service->getByIdqd($id);
        return ResponseUtil::success($data);
    }

    public function addqdtc() {
        // 获取请求的数据
        $data = request()->only([
            'num',
            'name',
            'TypeId',
            'ServerType',
            'ServerList',
            'TimeType',
            'TimeOpen',
            'TimeEnd',
            'LoopType',
            'LoopVal',
            'LoopDayTimeLimitStart',
            'LoopDayTimeLimitEnd',
            'DayRefreshTime',
            'UIInFuncId',
            'UIInFuncIdParam',
            'IsSysMsg',
            'Rebirth',
            'ExclusionAction',
            'serverGroup',
            'rmark'
        ]);

        // 添加创建时间
        $data['created_at'] = date("Y-m-d H:i:s");

        // 插入数据
        ActiveRuleQdTc::query()->insert($data);

        // 返回成功响应
        return ResponseUtil::success();
    }
}
